package com.xbb.bean;

import java.util.List;

/**
 * Created by xbb on 15/7/9.
 */
public class Sidebar {
    private Integer id;
    private String title;
    private String url;
    private String css_class;
    private Integer parent_id;
    private List<Sidebar> subMenu;
    private String requestUri;

    public List<Sidebar> getSubMenu() {
        return subMenu;
    }

    public void setSubMenu(List<Sidebar> subMenu) {
        this.subMenu = subMenu;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getCss_class() {
        return css_class;
    }

    public void setCss_class(String css_class) {
        this.css_class = css_class;
    }

    public Integer getParent_id() {
        return parent_id;
    }

    public void setParent_id(Integer parent_id) {
        this.parent_id = parent_id;
    }

    public String getRequestUri() {
        return requestUri;
    }

    public void setRequestUri(String requestUri) {
        this.requestUri = requestUri;
    }

    public boolean getIsActive(){
        if(requestUri.equals("") || requestUri==null || url.equals("") || url==null){
            return false;
        }
        System.out.println(url+"==========");
        int lastRequest=requestUri.lastIndexOf("/");
        String request=requestUri.substring(0,lastRequest);
        int lastUrl=url.lastIndexOf("/");
        String self = lastUrl > 0 ? url.substring(0,lastUrl) : url;
        return request.equals(self);
    }
}
